package com.combetter.changxing;


import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.combetter.changxing.base.BaseActivity;
import com.combetter.changxing.fragment.EquipmentFragment;
import com.combetter.changxing.fragment.HomeFragment;
import com.combetter.changxing.fragment.MineFragment;
import com.combetter.changxing.fragment.RecordFragment;
import com.combetter.changxing.utils.SPEngine;
import com.combetter.changxing.view.badge.BGABadgeImageView;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends BaseActivity {
    @Bind(R.id.fragment_layout)
    FrameLayout fragmentLayout;
    @Bind(R.id.biv_sy)
    BGABadgeImageView bivSy;
    @Bind(R.id.tv_sy)
    TextView tvSy;
    @Bind(R.id.ll_sy)
    LinearLayout llSy;
    @Bind(R.id.biv_sb)
    BGABadgeImageView bivSb;
    @Bind(R.id.tv_sb)
    TextView tvSb;
    @Bind(R.id.ll_sb)
    LinearLayout llSb;
    @Bind(R.id.biv_jl)
    BGABadgeImageView bivJl;
    @Bind(R.id.tv_jl)
    TextView tvJl;
    @Bind(R.id.ll_jl)
    LinearLayout llJl;
    @Bind(R.id.biv_wd)
    BGABadgeImageView bivWd;
    @Bind(R.id.tv_wd)
    TextView tvWd;
    @Bind(R.id.ll_wd)
    LinearLayout llWd;
    @Bind(R.id.rl_main)
    RelativeLayout rlMain;

    int id = R.id.fragment_layout;
    @Override
    protected int layoutId() {
        return R.layout.activity_main;
    }

    @Override
    protected void initViews() {
        showFragment(id, new HomeFragment());
        bivSy.setImageResource(R.mipmap.sy_shouye_sel);
        tvSy.setTextColor(getResources().getColor(R.color.colorPrimary));
    }

    @Override
    protected void loadData() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.ll_sy, R.id.ll_sb, R.id.ll_jl, R.id.ll_wd})
    public void onViewClicked(View view) {

        resetTab();
        switch (view.getId()) {
            case R.id.ll_sy:
                showFragment(id, new HomeFragment());
                bivSy.setImageResource(R.mipmap.sy_shouye_sel);
                tvSy.setTextColor(getResources().getColor(R.color.colorPrimary));
                break;
            case R.id.ll_sb:
                showFragment(id, new EquipmentFragment());
                bivSb.setImageResource(R.mipmap.sy_shebei_sel);
                tvSb.setTextColor(getResources().getColor(R.color.colorPrimary));
                break;
            case R.id.ll_jl:
                showFragment(id, new RecordFragment());
                bivJl.setImageResource(R.mipmap.sy_jilu_sel);
                tvJl.setTextColor(getResources().getColor(R.color.colorPrimary));
                break;
            case R.id.ll_wd:
                showFragment(id, new MineFragment());
                bivWd.setImageResource(R.mipmap.sy_wode_sel);
                tvWd.setTextColor(getResources().getColor(R.color.colorPrimary));
                break;
                default:
                    break;
        }
    }

    /**
     * set nor
     */
    private void resetTab() {
//
        bivSy.setImageResource(R.mipmap.sy_shouye_nor);
        tvSy.setTextColor(getResources().getColor(R.color.text_nor));
        bivSb.setImageResource(R.mipmap.sy_shebei_nor);
        tvSb.setTextColor(getResources().getColor(R.color.text_nor));
        bivJl.setImageResource(R.mipmap.sy_jilu_nor);
        tvJl.setTextColor(getResources().getColor(R.color.text_nor));
        bivWd.setImageResource(R.mipmap.sy_wode_nor);
        tvWd.setTextColor(getResources().getColor(R.color.text_nor));
    }

}
